import store from '@/jotais/store';
import { ConfigProvider, Result } from 'antd';
import zhCN from 'antd/locale/zh_CN'; // 导入中文语言包
import { Provider } from 'jotai';
import './app.less';
import { theme } from './theme';
// 运行时配置

// 全局初始化数据配置，用于 Layout 用户信息和权限初始化
// 更多信息见文档：https://umijs.org/docs/api/runtime-config#getinitialstate
export async function getInitialState(): Promise<{ name: string }> {
  return { name: '@umijs/max' };
}

export const layout = () => {
  return {
    logo: 'https://img.alicdn.com/tfs/TB1YHEpwUT1gK0jSZFhXXaAtVXa-28-27.svg',
    menu: {
      locale: false,
    },
    headerRender: false,
    unAccessible: (
      <Result status="403" title="403" subTitle="抱歉，你无权访问该页面." />
    ),
  };
};

export function rootContainer(container: JSX.Element) {
  return (
    <Provider store={store}>
      <ConfigProvider locale={zhCN} theme={theme} input={{ allowClear: true }}>
        {container}
      </ConfigProvider>
    </Provider>
  );
}
